package com.changgou.goods.service.impl;

import com.changgou.core.service.impl.CoreServiceImpl;
import com.changgou.goods.dao.CategoryMapper;
import com.changgou.goods.pojo.Brand;
import com.changgou.goods.pojo.Category;
import com.changgou.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/****
 * @Author:admin
 * @Description:Category业务层接口实现类
 * @Date 2019/6/14 0:16
 *****/
@Service
public class CategoryServiceImpl extends CoreServiceImpl<Category> implements CategoryService {

    private CategoryMapper categoryMapper;

    @Autowired
    public CategoryServiceImpl(CategoryMapper categoryMapper) {
        super(categoryMapper, Category.class);
        this.categoryMapper = categoryMapper;
    }

    /**
     * 根据id查询所有目录
     * @param pid
     * @return
     */
    @Override
    //select * from tb_category where parent_id = ?
    public List<Category> findByParentId(Integer pid) {
        //这个是查询条件相当于 where
        Category t = new Category();
        //这个相当于parent_id = ？（pid）
        t.setParentId(pid);
        //如果还有就可以继续加这个就相当于and name = ？（手机）
        //t.setName("手机");
        //t是条件 这个select方法相当于 select * from tb_category
        List<Category> categoryList = categoryMapper.select(t);
        return categoryList;
    }
}
